<? require("adm_header.php"); 
writeCommonAdminTable(LA_ADMINS_TITLE,1);


echo "<b>".LA_ADMINS_TITLE."</b><br />";
echo LA_ADMINS_DESCR;

if (!$set_level_permissions)
{
	echo "<br /><br /><b>".LA_ADMINS_NOTICE.":</b> <a href='adm_set.php?file=opt_inc.php#set_level_permissions'><u>".LA_ADMINS_LEVEL_PERM."</u></a>.";
}
?>
<br /><br /> 
<br /><br /><form method='post' action='adm_users.php'>
<? echo '<input type="submit" name="create_new" value="'.LA_ADMINS_CREATE_NEW .'" />'; ?></form><br /><br />
</form>
<br /><br />

<?
if (WA())
{
	if (getParam("create_new",""))
		q("insert into $adm_tbl (adm_name) values ('')");
	if (getParam("delete",""))
		q("delete from $adm_tbl where adm_id=".getParam("adm_id",""));
	if (getParam("update",""))
	{
		q("update $adm_tbl set adm_name='". getParam("adm_name","") . "', adm_level=". getParam("adm_level",0) . " where adm_id=".getParam("adm_id",""));
		if (getParam("adm_pass","")!="")
			q("update $adm_tbl set adm_pass=md5('". getParam("adm_pass","") . "') where adm_id=".getParam("adm_id",""));

			
		echo "<p>".LA_ADMINS_USER_UPDATED."</p>";
	}
		
}
else 
{	
	echo "<p>Demo-mode: No action will be performed!</p>";	
}
	
$sql="select * from $adm_tbl";
if (!WA())
	$sql.=" where adm_id=" . strToDb($_SESSION["admin"]);
$r=q($sql);
$lLevels[0]="". LA_ADMINS_FULL_ACCESS . "";
$lLevels[1]="Level One";
$lLevels[2]="Level Two";
$lLevels[3]="Level Three";

$i=0;
while ($row=mysql_fetch_array($r))
{
	$i++;
	echo "<form method='post' action='adm_users.php' style='margin:0px'>";
	echo "<input type='hidden' name='adm_id' value='".$row["adm_id"]."'>";
	echo "<table><tr";
	if ($i==2)
	{
		echo " class='alt'";
	}
	echo "><td>".LA_ADMINS_USER.":</td><td><input type='text' class='txt' name='adm_name' value='".$row["adm_name"] . "'></td></tr>";
	echo "<tr><td>".LA_ADMINS_PASS.":</td><td><input type='password' class='txt' name='adm_pass' value=''></td></tr>";
	echo "<tr><td>".LA_ADMINS_LEVEL."</td><td><select class='txt' name='adm_level'>" . getDDFromList($lLevels,$row["adm_level"]) . "</select></td></tr>";
	echo "<tr><td colspan='2'><input type='submit' name='update' value='".LA_ADMINS_UPDATE."' class='txt'>";
	echo "&nbsp;<input type='submit' name='delete' value='".LA_ADMINS_DELETE."' class='txt'></td></tr></table>";	
	
	
	if ($i==2)
		$i=0;
	
	echo "</form><br />";
}



writeCommonAdminTable("","");
require("adm_footer.php"); ?>
